package com.hashnode.srpingboot_0002_restfultest.controller;

import com.hashnode.srpingboot_0002_restfultest.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

//@Controller
//@ResponseBody

@RestController
@RequestMapping("/users")
public class UserController_2 {
//    @RequestMapping(method = RequestMethod.POST)
    @PostMapping
    public String sava(){
        System.out.println("user save.....");
        return "{'module':'user save'}";
    }


//    @RequestMapping(method = RequestMethod.PUT)
    @PutMapping
    public String update(@RequestBody User user){
        System.out.println("user update....." + user);
        return "{'module':'user update'}";
    }

//    @RequestMapping(method = RequestMethod.GET)
    @GetMapping
    public String getAll(){
        System.out.println("user getAll.....");
        return "{'module':'user getAll'}";
    }

//    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    @GetMapping("/{id}")
    public User getById(@PathVariable Integer id){
        System.out.println("user getById....." + id);
        return new User("aaa","bbb");
    }

//    @RequestMapping(value = "/{id}",method = RequestMethod.DELETE)
    @DeleteMapping("/{id}")
    public String delete(@PathVariable Integer id){
        System.out.println("user delete....." + id);
        return "{'module':'user delete'}";
    }
}
